JgfNode.constructor   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
const { Guard } = require('./guard');
2
3
/**
4
 * A node object represents a node in a graph. In graph theory, nodes are also called points or vertices.
5
 */
6
class JgfNode {
7
8
    /**
9
     * Constructor
10
     * @param {string} id Primary key for the node, that is unique for the object type.
11
     * @param {string} label A text display for the node.
12
     * @param {object|null} metadata Metadata about the node.
13
     */
14
    constructor(id, label, metadata = null) {
15
        this.id = id;
16
        this.label = label;
17
        this.metadata = metadata;
18
    }
19
20
    set metadata(metadata) {
21
        Guard.assertValidMetadataOrNull(metadata);
22
        this._metadata = metadata;
23
    }
24
25
    get metadata() {
26
        return this._metadata;
27
    }
28
}
29
30
module.exports = {
31
    JgfNode,
32
};